import type {
  MemberCardLogsParams,
  MemberCardLogsResponse,
  MemberDetailResponse,
  MemberListResult,
  AddUserParams,
  MemberUserInfo,
  UserConsumerParams,
  UserPayParams,
  UserTodaySummaryData,
} from '@/api/model/memberModel';
import { Result } from '@/types/axios';
import { request } from '@/utils/request';

const Api = {
  MemberList: '/user/list',
  UserTodaySummary: '/user/user/today/summary',
  UserAddUser: '/user/addUser',
  UserAddTempUser: '/user/addTmpUser',
  UserPay: '/user/pay',
  UserConsumer: '/user/consumer',
  UserUserInfo: '/user/card/info',
  UserCardLogs: '/user/card/logs',
  UserImportInit: '/user/import/init',
  UserExportExport: '/user/export',
};

export function getMemberList(data: any) {
  return request.post<MemberListResult>({
    url: Api.MemberList,
    data,
  });
}
export function getUserTodaySummary() {
  return request.post<Result>({
    url: Api.UserTodaySummary,
  });
}
export function addMemberUser(data: AddUserParams) {
  return request.post({
    url: Api.UserAddUser,
    data,
  });
}

export function addTempMemberUser(data: AddUserParams) {
  return request.post({
    url: Api.UserAddTempUser,
    data,
  });
}

export function userPay(data: UserPayParams) {
  return request.post<Result>({
    url: Api.UserPay,
    data,
  });
}

export function UserConsumer(data: UserConsumerParams) {
  return request.post<Result>({
    url: Api.UserConsumer,
    data,
  });
}

export function UserUserInfo(data: MemberUserInfo) {
  return request.post<MemberDetailResponse>({
    url: Api.UserUserInfo,
    data,
  });
}

export function UserCardLogs(data: MemberCardLogsParams) {
  return request.post<MemberCardLogsResponse>({
    url: Api.UserCardLogs,
    data,
  });
}

export function UserImportInit(data: any) {
  return request.post<any>({
    url: Api.UserImportInit,
    data,
  });
}

export function UserExportExport(data: any) {
  return request.post<any>({
    url: Api.UserExportExport,
    data,
    responseType: 'blob',
  });
}
